# from django.test import TestCase
#
# # Create your tests here.
# import datetime,pytz
# t = datetime.datetime.now()
# # datetime.datetime(2018, 2, 22, 11, 18, 15, 623160)
# print(t)
# new_t = t.replace(tzinfo=(pytz.timezone('Asia/Shanghai')))
# print(new_t)
# aaa = pytz.timezone('Asia/Shanghai')
# print(aaa)
# print(type(aaa))
# print(aaa.__dict__)
# print(aaa.zone)
# print(type(aaa.zone))
# # datetime.datetime(2018, 2, 22, 11, 18, 15, 623160, tzinfo=<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>)


from threading import Thread, currentThread, active_count, enumerate, Lock
import time

# def task():
#     print('%s is ruuning' % currentThread().getName())
#     time.sleep(2)
#     print('%s is done' % currentThread().getName())
#
#
# if __name__ == '__main__':
#     t = Thread(target=task, name='子线程')
#     # t.setDaemon(True)  # 守护线程 随着主线程消亡而消亡，必须在t.start()之前
#     t.daemon = True  # 守护线程 随着主线程消亡而消亡，必须在t.start()之前
#     t.start()
#     # t.join()  # 阻塞住等待t运行完毕再往下执行
#     t.setName('儿子线程')  # 修改线程名
#     print(t.getName())  # 获取线程名
#     currentThread().setName('主线程')  # 修改主线程名称
#     print(t.isAlive())  # 查看线程是否存活
#     print('主线程',currentThread().getName())  # 获取主线程名称
#     print(active_count())  # 获取活跃线程数
#     print(enumerate())  # 获取活跃线程


# n = 100
# # bzlg  2954
#
# def task():
#     global n
#     mutex.acquire()
#     temp = n
#     time.sleep(0.1)
#     n = temp - 1
#     mutex.release()
#
#
# if __name__ == '__main__':
#     mutex = Lock()
#     t_l = []
#     for i in range(100):
#         t = Thread(target=task)
#         t_l.append(t)
#         t.start()
#     for t in t_l:
#         t.join()
#     print('主', n)

# from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
#
# import os, time, random
#
#
# def task(n):
#     print('%s is runing' % os.getpid())
#     time.sleep(random.randint(1, 3))
#     return n ** 2
#
#
# if __name__ == '__main__':
#
#     executor = ProcessPoolExecutor(max_workers=3)
#
#     futures = []
#     for i in range(11):
#         future = executor.submit(task, i)
#         futures.append(future)
#     executor.shutdown(True)
#     print('+++>')
#     for future in futures:
#         print(future.result())


# from concurrent.futures import ThreadPoolExecutor,ProcessPoolExecutor
#
# import os,time,random
# def task(n):
#     print('%s is runing' %os.getpid())
#     time.sleep(random.randint(1,3))
#     return n**2
#
# if __name__ == '__main__':
#
#     executor=ThreadPoolExecutor(max_workers=3)
#
#     # for i in range(11):
#     #     future=executor.submit(task,i)
#
#     executor.map(task,range(1,12)) #map取代了for+submit


# from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
# from multiprocessing import Pool
# import requests
# import json
# import os
#
#
# def get_page(url):
#     print('<进程%s> get %s' % (os.getpid(), url))
#     respone = requests.get(url)
#     if respone.status_code == 200:
#         return {'url': url, 'text': respone.text}
#
#
# def parse_page(res):
#     res = res.result()
#     print('<进程%s> parse %s' % (os.getpid(), res['url']))
#
#
# if __name__ == '__main__':
#     urls = [
#         'https://www.baidu.com',
#         'https://www.python.org',
#         'https://www.openstack.org',
#         'https://help.github.com/',
#         'http://www.sina.com.cn/'
#     ]
#     t1 = time.time()
#     # p = ProcessPoolExecutor(3)
#     p = ThreadPoolExecutor(3)
#     for url in urls:
#         p.submit(get_page, url).add_done_callback(parse_page)  # parse_page拿到的是一个future对象obj，需要用obj.result()拿到结果
#     t2 = time.time()
#     print(t2-t1)

# import time
# from gevent import monkey;monkey.patch_all()
#
# import gevent
#
# from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
# from multiprocessing import Pool
# class Test:
#     def __init__(self):
#         self.test_data = {
#             'ceses': 0,
#         }
#         self.gts = []
#         self.nb = 100
#
#     def add(self):
#         time.sleep(1)
#         self.test_data['ceses'] += 1
#
#     # def exe_func(self):
#     #     for i in range(self.nb):
#     #         g = gevent.spawn(self.add)
#     #         self.gts.append(g)
#     #     gevent.joinall(self.gts)
#
#     # def exe_func(self):
#     #     for i in range(self.nb):
#     #         g = gevent.spawn(self.add)
#     #         self.gts.append(g)
#     #     gevent.joinall(self.gts)
#
#     def pt(self):
#         print(self.test_data)
#
#
# if __name__ == '__main__':
#     # obj = Test()
#     # t1 = time.time()
#     # obj.exe_func()
#     # t2 = time.time()
#     # print(t2 - t1)
#     # obj.pt()
#     obj = Test()
#     executor = ThreadPoolExecutor(100)
#     t1 = time.time()
#     # futures = []
#     for i in range(obj.nb):
#         # p.submit(obj.add).add_done_callback(parse_page)  # parse_page拿到的是一个future对象obj，需要用obj.result()拿到结果
#         future = executor.submit(obj.add)
#         # futures.append(future)
#     executor.shutdown(True)
#     # for future in futures:
#     #     print(future.result())
#     t2 = time.time()
#     cc = t2-t1
#     print(cc)
#     obj.pt()
#     print(type(t1))
#     cc = round(cc, 4)
#     print(type(cc))
#     print(cc)

# 线程数
th = 100
cases_count = 1000*10
exe_time = 60*4
t = cases_count/th*exe_time
h = t/3600
h = round(h,2)
print('耗时：{h}小时'.format(h=h))
